import instance from "../utils/http"
// 请求所有数据
export const manageServer = async () => {
    const url = '/api/mockList/users'
    const data = await instance.get(url)
    return data
}

// 
export const updIsStar = async (_id: string, isStar?: boolean, isDeleted?: boolean) => {
    const url = '/api/mockList/upd';
    const body = { _id, isStar, isDeleted };
    console.log(_id, isStar, isDeleted);
    try {
        const data = await instance.patch(url, body);
        return data;
    } catch (error) {
        console.error('Error updating item:', error);
        // 可以根据需要抛出错误或返回某种错误状态
        throw error;
    }
}

export const delSelect = async (_id: string) => {
    const url = '/api/mockList/del';
    const body = { _id, };
    console.log(_id);
    try {
        const data = await instance.post(url, body);
        return data;
    } catch (error) {
        console.error('Error updating item:', error);
        // 可以根据需要抛出错误或返回某种错误状态
        throw error;
    }
}

export const find_one = async (_id: string) => {
    const url = '/api/mockList/find_one';
    const body = { _id, };
    console.log(_id);
    try {
        const data = await instance.post(url, body);
        return data;
    } catch (error) {
        console.error('Error updating item:', error);
        // 可以根据需要抛出错误或返回某种错误状态
        throw error;
    }
}

